package com.imooc.mall.controller;

import com.github.pagehelper.PageInfo;
import com.imooc.mall.common.ApiRestResponse;
import com.imooc.mall.model.pojo.Product;
import com.imooc.mall.model.request.ProductListReq;
import com.imooc.mall.service.ProduceService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 前台商品controller
 */
@RestController
public class ProductController {

    @Autowired
    private ProduceService productservice;

    /**
     * 前台查看商品
     */
    @ApiOperation("前台商品查询功能")
    @PostMapping("product/detail")
    public ApiRestResponse detail(@RequestParam Integer id){
        Product detail = productservice.detail(id);
        return ApiRestResponse.success(detail);
    }

    /**
     * 查询商品详情功能
     */

    @ApiOperation("查询商品详情功能")
    @PostMapping("/product/list")
    public ApiRestResponse list(ProductListReq productListQeq){

        PageInfo list = productservice.list(productListQeq);
        return ApiRestResponse.success(list);

    }

}
